﻿#region Using References

using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Beaker.OpenCube.Game;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;

#endregion

namespace Beaker.OpenCube.Specs.Game
{
	[ExcludeFromCodeCoverage]
	[TestClass]
	public class GeneratorOptionsSpecs
	{
		[TestMethod]
		public void Parse()
		{
			// arrange
			const string settingsString = "2;7,59x1,3x3,2,78:2;1;stronghold(count=7),biome_1,village(size=0 distance=0),decoration,dungeon,mineshaft";

			// act
			GeneratorOptions settings;
			bool success = GeneratorOptions.TryParse( settingsString, out settings );

			// assert
			success.Should().Be( true );
			settings.Layers.Should().ContainInOrder(
				new[]
				{
					new GeneratorLayerOptions( BlockType.Bedrock ),
					new GeneratorLayerOptions( 59, BlockType.Stone ),
					new GeneratorLayerOptions( 3, BlockType.Dirt ),
					new GeneratorLayerOptions( BlockType.Grass )
				}
			);
			settings.Biome.Should().Be( BiomeType.Plains );
			settings.StructureOptions.Count.Should().Be( 6 );
			settings.StructureOptions.Should().Contain( 
				new[] 
				{
					new GeneratorStructureOption( "stronghold", new Dictionary<string, int> { { "count", 7 } } ),
					new GeneratorStructureOption( "biome_1" ),
					new GeneratorStructureOption( "village", new Dictionary<string, int> { { "size", 0 }, { "distance", 0 } } ),
					new GeneratorStructureOption( "decoration" ),
					new GeneratorStructureOption( "dungeon" ),
					new GeneratorStructureOption( "mineshaft" )
				}
			);
		}
	}
}
